#include "ClientCfg.h"

ClientCfg::ClientCfg(std::string& path_cfg) {
	this->path_cfg = path_cfg;
}

const char* ClientCfg::getNameFieldIp(){
	return "SERVER_IP";
}
const char* ClientCfg::getNameFieldStoragePath(){
	return "AU_DIRECTORY";
}
const char* ClientCfg::getNameFieldPort(){
	return "PORT";
}
const char* ClientCfg::getNameFieldPolling(){
	return "POLLING_TIME";
}
const char* ClientCfg::getNameFieldIndexPath(){
	return "INDEX_PATH";
}
const char* ClientCfg::getNameFieldLoginPath(){
	return "LOGIN_PATH";
}

void ClientCfg::Initialize() {
		Index idx(&path_cfg);
		idx.LoadFromDisk();
		string server_ip_key(this->getNameFieldIp());
		string au_folder_key(this->getNameFieldStoragePath());
		string port_key(this->getNameFieldPort());
		string polling_time_key(this->getNameFieldPolling());
		string indice_path_key(this->getNameFieldIndexPath());
		string login_path_key(this->getNameFieldLoginPath());
		ip_server=idx.GetSecond(&server_ip_key);
		storage_path=idx.GetSecond(&au_folder_key);
		port=atoi(idx.GetSecond(&port_key).c_str());
		polling=atoi(idx.GetSecond(&polling_time_key).c_str());
		indice_path =idx.GetSecond(&indice_path_key);
		login_path = idx.GetSecond(&login_path_key);
}

std::string ClientCfg::getIp_server(){
	return ip_server;
}

std::string ClientCfg::getStorage_path(){
	return storage_path;
}

int ClientCfg::getPort(){
	return port;
}
std::string ClientCfg::getIndice_path(){
	return indice_path;
}

std::string ClientCfg::getLogin_path(){
	return login_path;
}
int ClientCfg::getPolling(){
	return polling;
}

ClientCfg::~ClientCfg() {
}

